import com.java.demo.component.BeanCompoent;
import com.java.demo.controller.UserController;
import com.java.demo.controller.UserController2;
import com.java.demo.enity.User;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

// 启动类
public class App {
    public static void main(String[] args) {
        // 1.获取到spring对象,配置扫描路径
//        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");

        // 2.获取到bean对象,名称加类型
//        UserController userController = context.getBean("userController",UserController.class);
//        userController.printUser();

//        User user = context.getBean("newUser",User.class);
//        System.out.println(user.getUserId());

//        UserController2 userController2 = context.getBean("userController2",UserController2.class);
//        userController2.printUser();


        ClassPathXmlApplicationContext context1 = new ClassPathXmlApplicationContext("spring-config.xml");
        BeanCompoent beanCompoent = context1.getBean("beanCompoent", BeanCompoent.class);
        beanCompoent.sayHi();
        beanCompoent.doPreDestroy();
    }
}
